﻿<!DOCTYPE HTML>
<html>
<head>
<title>权限管理</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<#include "/views/ftl/base/manager_include.ftl">
</head>
<body style="background:#eef3f7;">
<#include "/views/ftl/base/head.ftl">
<div class="Main">
  <div class="dw">
<#include "/views/ftl/base/menu.ftl">
<#function a><#return "管理员列表_List"></#function> 
      <!--右边内容-->
 	<div class="Rightbox fl">
        <!--面包屑-->
        <div class="Bread_crbs clear">
          <div class="Bread_crbs_img fl"></div>
          <div class="Bread_crbs_text fl">
          	<a href="javascript:;">
          		<span>管理员列表-></span>
          	</a>
          	<span class="fnt_famy"></span>
          	<a href="javascript:;">
          		<span>角色设置</span>
          	</a>
          </div>
        </div>
        <!--各种表单设置-->
        <form id="post_infor" name="post_infor" action="${basePath}manager/Manager_addManager" method="post">
        
       <div>
            <div ><input type="hidden" value="${id?c}" name="id">
                <table cellspacing="0" cellpadding="0" class="mainForm">
                    <tbody class="input_name"><tr>
						<td width="100">角色</td>
                        <td><select class="SelectStyle" size="10" multiple="true" name="roleIdList">
       		        <#if (list??)> 
        		 <#if ((list?size)>0)>
         		 <#list list as bean>
                                <option value="${(bean.id)?c}">${(bean.name)!''}</option>
                             </#list >
			      </#if>
			       </#if>
                            </select>
                            按住Ctrl键可以多选或取消选择
                        </td>
                    </tr>
                </tbody></table>
            </div>
        </div>
         <div class="clear"></div>
        <div class="button">
          <a href="javascript:save();"><input type="button" id="save_button" name="button" value="保存" /></a>
        </div>

        </form>
      </div>
  </div>
</div>

<script type="text/javascript">
    	$(function(){
    	//$('select[name="roleIdList"]').val('${resourceIdList}');
	var hx='${resourceIdList}';
 	 var hh = hx.split(",");
	$('select[name="roleIdList"]').children().each(function(){
		 for(var i=0;i<hh.length;i++){
			 if($(this).attr('value')==hh[i]){
				 $(this).attr('selected','selected');
			 }
		 }
	});
    	});

	//保存帖子信息
	function save(){
 	var idq=$('select[name="roleIdList"]').val();
    	var ids=idq.toString();
        if(idq==""){
        alert("请选择至少一个选项");
        return;
        }
 	$.ajax({ 
			url : "${basePath }manager/Manager_setRole",
			data : { 
				id: ${id},
				ids: ids,
			}, 
			dataType :"JSON",
			cache : false, 
			type : "POST",
			success : function(dat){
				if(dat.code==1){
				alert(dat.msg);
		        	window.location.href="${basePath }manager/Manager_managerList"; 
				}else if(dat.code==0){
					alert(dat.msg);
				} 	
			}
		});
	
}
</script>
</body>
</html>
